import Cookies from "js-cookie";

export function getCurrentAuthority() {
  const user = JSON.parse(Cookies.get("user"));
  //后台返回当前用户的权限
  let auths = user.authorities;
  let temp = [];
  for (let i = 0; i < auths.length; i++) {
    temp.push(auths[i].authority);
  }
  return temp;
}

export function check(authority) {
  const current = getCurrentAuthority();
  return current.some(item => authority.includes(item));
}

export function isLogin() {
  let user = Cookies.get("user");
  // if (!user) return false
  return user;
}
